package com.itheima.test;


import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
import com.aliyun.teaopenapi.models.Config;

public class Sample {

    public static void main(String[] args_) throws Exception {

        String accessKeyId = "LTAI5tFzUPSsSokQDv8buGZz";
        String accessKeySecret = "aHcA1ptL54sy9k4dE6VpX7DWIqJIjn";

        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);

        // 访问的域名
        config.endpoint="dysmsapi.aliyuncs.com";
        com.aliyun.dysmsapi20170525.Client client = new com.aliyun.dysmsapi20170525.Client(config);
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers("15518766562") //目标手机号
                .setSignName("探花交友") //签名名称
                .setTemplateCode("SMS_204756728") //短信模板code
                .setTemplateParam("{\"code\":\"1111\"}"); //模板中变量替换
        SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
        SendSmsResponseBody body = sendSmsResponse.getBody();
        // code = OK 代表成功
        System.out.println(body.getCode() + "  " + body.getMessage());
    }
}
